/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.hnilica.emailer;

import java.util.Comparator;

/**
 * Comparator for Termin. At the first compare terms of cleaning (terCis). On the top
 * puts later date. Year 2000 is higher then 1900. If dates is same then
 * sorts naem of street lixicongraphiclly by using String method compareToIgnoreCase.
 * @author swosh
 */
public class TerminComparator implements Comparator<Termin> {

    public int compare(Termin o1, Termin o2) {
        int result = o1.getTerCis().compareTo(o2.getTerCis());
        if (result > 0) {
            return -1;//diferent of navive
        } else if (result < 0) {//this.terCis before o.terCis
            return 1;//diferent of navive
        } else {
            result = o1.getNazev().compareToIgnoreCase(o2.getNazev());
            if (result > 0) {
                return 1;
            } else if (result < 0) {
                return -1;
            } else {
                return 0;
            }
        }

    }

}
